import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import path from 'node:path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import Inspect from 'vite-plugin-inspect'
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(),
    AutoImport({
      resolvers: [ElementPlusResolver(),
        AntDesignVueResolver()
      ],
    }),
    Components({
      // 自动发现并注册组件
      dirs: ['src/components'], // 组件目录
      extensions: ['vue'],
      dts: true, // 生成类型声明文件
      resolvers: [ElementPlusResolver()],
    }),
  createSvgIconsPlugin({
      // 确保路径指向实际存放SVG的目录
      iconDirs: [path.resolve(process.cwd(), 'src/questionare/icons/svg')],
      
      // 指定symbol ID格式（正确）
      symbolId: "icon-[name]",
      
      // 插入位置（推荐）
      inject: "body-last",
      
      // 自定义SVG DOM ID（可选）
      customDomId: "__svg__icons__dom__"
    }),
    Inspect({
      build:true,
      outputDir:'.vite-inspect',
    }),
  ],
  resolve:{
    alias:{
      "@":path.resolve(__dirname,'./src')
    }
  }
})
